<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>活动-图书详情列表</title>
<link rel="icon" href="favicon.ico" type="image/ico">

<link href="/Public/Admin/css/bootstrap.min.css" rel="stylesheet">
<link href="/Public/Admin/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/Public/Admin/js/bootstrap-datepicker/bootstrap-datepicker3.min.css" rel="stylesheet">
<link href="/Public/Admin/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet">
<link href="/Public/Admin/js/bootstrap-clockpicker/bootstrap-clockpicker.min.css" rel="stylesheet">
<link href="/Public/Admin/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/Public/Admin/css/animate.min.css" rel="stylesheet">
<link href="/Public/Admin/css/style.min.css" rel="stylesheet">
</head>

<body>
<div class="container-fluid p-t-15">
  <div class="col-lg-12">
      <div class="card">
        <header class="card-header"><div class="card-title">步骤</div></header>
        <div class="card-body">
          
          <ul class="nav nav-step nav-fill">
            <li class="nav-item">
              <span>活动基本信息</span>
              <a class="nav-link active" href="#"></a>
            </li>
  
            <li class="nav-item">
              <span>捐赠书籍添加</span>
              <a class="nav-link active" href="#"></a>
            </li>
  
            <li class="nav-item">
              <span>完成</span>
              <a class="nav-link active" href="#"></a>
            </li>

          </ul>
        </div>
      </div>
    </div>
  <div class="row">
    <div class="col-lg-12">
      <div class="card">

        <div class="card-body">
          <!--这里展示活动信息-->
			<form action="#" method="post" name="editActivity" id="editActivity" class="editActivity">
			<input type="text" id="id" name="id" class="id" value="<?php echo $activityArrs['activity_id'];?>" style="display:none" />
            <div class="form-group col-md-12">
              <label for="seo_description">活动名</label>
              <input class="form-control" type="text" id="activity_name" name="activity_name" value="<?php echo $activityArrs['activity_name'];?>" />
            </div>

            <div class="form-group col-md-12">
              <label for="tags">活动地点</label>
              <input class="form-control" type="text" id="activity_place" name="activity_place" value="<?php echo $activityArrs['activity_place'];?>" />
            </div>
			<div class="form-group col-md-12">
              <label for="sort">合作方1</label>
              <input type="text" class="form-control" id="activity_partner_a" name="activity_partner_a" value="<?php echo $activityArrs['activity_partner_a'];?>" />
			  <label for="sort">合作方2</label>
              <input type="text" class="form-control" id="activity_partner_b" name="activity_partner_b" value="<?php echo $activityArrs['activity_partner_b'];?>" />
			  <label for="sort">合作方3</label>
              <input type="text" class="form-control" id="activity_partner_c" name="activity_partner_c" value="<?php echo $activityArrs['activity_partner_c'];?>" />
            </div>
			<div class="form-group col-md-12">
              <label for="sort">受益方</label>
              <input type="text" class="form-control" id="activity_recipient" name="activity_recipient" value="<?php echo $activityArrs['activity_recipient'];?>" />
            </div>
			<div class="form-group col-md-12">
              <label for="sort">开始时间</label>
              <input type="text" data-side-by-side="true" data-provide="datetimepicker" class="form-control" id="activity_begin" name="activity_begin" value="<?php echo $activityArrs['activity_begin'];?>" data-format="YYYY-MM-DD HH:mm:ss" />
            </div>
			<div class="form-group col-md-12">
              <label for="sort">结束时间</label>
              <input type="text" data-side-by-side="true" data-provide="datetimepicker" class="form-control" id="activity_end" name="activity_end" value="<?php echo $activityArrs['activity_end'];?>" data-format="YYYY-MM-DD HH:mm:ss" />
            </div>
			<div class="form-group col-md-12">
              <label for="sort">捐书数量</label>
              <input type="text" class="form-control" id="activity_book" name="activity_book" value="<?php echo $activityArrs['activity_book'];?>" />
            </div>
			<div class="form-group col-md-12">
              <label for="sort">金额</label>
              <input type="text" class="form-control" id="activity_money" name="activity_money" value="<?php echo $activityArrs['activity_money'];?>" />
            </div>
            
            
			<div class="form-group col-md-12">
              <label for="sort">活动类型（0对外、1对内）</label>
             <br>
             <!--<input type="text" class="form-control" id="activity_type" name="activity_type" value="<?php echo $activityArrs['activity_type'];?>" />-->
             
			<div class="custom-control custom-radio custom-control-inline">
	        <input type="radio" id="activity_type1" name="activity_type" class="custom-control-input" value="0"
	        <?php if($activityArrs['activity_type']==0){ ?> checked <?php }?>
	        >
	        <label class="custom-control-label" for="activity_type1">对外捐赠</label>
			</div>
			<div class="custom-control custom-radio custom-control-inline">
				<input type="radio" id="activity_type2" name="activity_type" class="custom-control-input"  value="1"
				 <?php if($activityArrs['activity_type']==1){ ?> checked <?php }?>
				>
				<label class="custom-control-label" for="activity_type2">内部活动</label>
			</div>
            </div>
            
			<div class="form-group col-md-12">
			    <span class="d-inline-block" data-toggle="popover" data-content="（0未开始、1已开始、2已结束、3其他，且不能在这里设置活动状态，这样会影响库存表的数量，应当在列表页进行操作，系统便会自动化进行库存操作）">
              <label for="sort">活动状态</label>
              <!--<input type="text" class="form-control" id="activity_status" name="activity_status" value="<?php echo $activityArrs['activity_status'];?>" />-->
              <br>
              <div class="custom-control custom-radio custom-control-inline">
	        <input type="radio" id="activity_status1" name="activity_status" class="custom-control-input" value="0"
	        <?php if($activityArrs['activity_status']==0){ ?> checked <?php }?>
	        disabled>
	        <label class="custom-control-label" for="activity_status1">未开始</label>
			</div>
			<div class="custom-control custom-radio custom-control-inline">
				<input type="radio" id="activity_status2" name="activity_status" class="custom-control-input"  value="1"
				 <?php if($activityArrs['activity_status']==1){ ?> checked <?php }?>
				disabled>
				<label class="custom-control-label" for="activity_status2">已开始</label>
			</div>
			<div class="custom-control custom-radio custom-control-inline">
				<input type="radio" id="activity_status3" name="activity_status" class="custom-control-input"  value="2"
				 <?php if($activityArrs['activity_status']==2){ ?> checked <?php }?>
				disabled>
				<label class="custom-control-label" for="activity_status3">已结束</label>
			</div>
			<div class="custom-control custom-radio custom-control-inline">
				<input type="radio" id="activity_status4" name="activity_status" class="custom-control-input"  value="3"
				 <?php if($activityArrs['activity_status']==3){ ?> checked <?php }?>
				disabled>
				<label class="custom-control-label" for="activity_status4">其它</label>
			</div>
            </div>
            
            
            <div class="form-group col-md-12">
                <?php if($activityArrs['activity_status']==2){ ?>
                      <button type="button" class="btn btn btn-secondary">活动已结束，不可操作</button>
                      <?php }else{?>
              <button id="submitbtn" type="submit" class="btn btn-success ajax-post confirm" target-form="editActivity">确 定</button>
              <button type="button" class="btn btn-default" onclick="javascript:history.back(-1);return false;">返 回</button>
              <a href="?c=Activity&a=addActivityBookView&id=<?php echo $activityArrs['activity_id'];?>"><button type="button" class="btn btn-cyan btn-w-md">添加书籍</button></a>
            </div>
            <?php }?>
          </form>
			
			
			<!--下面用来展示书籍-->
          <div class="table-responsive">
            <table class="table table-bordered">
              <thead>
                <tr>
                 
                  <th>ID</th>
                  <th>书籍ID</th>
                  <th>书籍名称</th>
                  <th>捐赠数量</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
				  
				  <?php foreach($activityBookArrs as $arr){?>
				  
                <tr>
                  
					
                  <td><?php echo $arr['book_whereabouts_id'];?></td>
                  <td><?php echo $arr['book_id'];?></td>
                  <td><?php echo $arr['book_name'];?></td>
				  <td><?php echo $arr['book_count'];?></td>

					
                  <td>
                    <div class="btn-group">
                      <!--<a class="btn btn-xs btn-default" href="?c=Activity&a=editActivityView&id=<?php echo $arr['activity_id'];?>" title="" data-toggle="tooltip" data-original-title="编辑"><i class="mdi mdi-pencil"></i></a>-->
                      <?php if($activityArrs['activity_status']==2){ ?>
                      活动已结束，不可操作
                      <?php }else{?>
                      <a class="btn btn-xs btn-default ajax-get confirm" href="?c=Activity&a=delActivityBook&id=<?php echo $arr['book_whereabouts_id'];?>&aid=<?php echo $activityArrs['activity_id'];?>" title="" data-toggle="tooltip" data-original-title="删除"><i class="mdi mdi-window-close"></i></a>
                      <?php }?>
                    </div>
                  </td>
                </tr>
                
				  <?php } ?>
				  
				  
              </tbody>
            </table>
          </div>

 
        </div>
      </div>
    </div>
    

    
  </div>
  
</div>
<script type="text/javascript" src="/Public/Admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/popper.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/lyear-loading.js"></script>
<script type="text/javascript" src="/Public/Admin/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/main.min.js"></script>
<!--时间日期选择器-->
<script type="text/javascript" src="/Public/Admin/js/moment.js/moment.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/moment.js/locale/zh-cn.min.js"></script>
<script type="text/javascript">
$(function(){
    $('.search-bar .dropdown-menu a').click(function() {
        var field = $(this).data('field') || '';
        $('#search-field').val(field);
        $('#search-btn').html($(this).text());
    });
    
    // 通用ajax get请求
    jQuery(document).delegate('.ajax-get', 'click', function(){
        var self = $(this), tips = self.data('tips'), ajax_url = self.attr("href") || self.data("url");
        
        if (self.hasClass('confirm')) {
            $.confirm({
                title: '',
                content: tips || '确认要执行该操作吗？',
                type: 'orange',
                typeAnimated: true,
                buttons: {
                    confirm: {
                        text: '确认',
                        btnClass: 'btn-blue',
                        action: function() {
                            var loader = $('body').lyearloading({
                                opacity: 0.2,
                                spinnerSize: 'lg'
                            });
                            self.attr('autocomplete', 'off').prop('disabled', true);
                            
                            ajaxGetFun(self, ajax_url, loader);
                        }
                    },
                    cancel: {
                        text: '取消',
                        action: function() {}
                    }
                }
            });
            return false;
        } else {
            var loader = $('body').lyearloading({
                opacity: 0.2,
                spinnerSize: 'lg'
            });
            self.attr('autocomplete', 'off').prop('disabled', true);
            
            ajaxGetFun(self, ajax_url, loader);
        }
        return false;
    });
    

    
    // GET提交处理
    function ajaxGetFun(selfObj, ajax_url, loader) {
        console.log(ajax_url);
        jQuery.get(ajax_url).done(function(res) {
            loader.destroy();
            var res = eval('(' + res + ')');
            var msg = res.msg;
            if (200 == res.code) {
                if (res.url && !selfObj.hasClass('no-refresh')) {
                    msg += '页面即将自动跳转';
                }
                showNotify(msg, 'info');
                setTimeout(function () {
					selfObj.attr("autocomplete", "on").prop("disabled", false);
					return selfObj.hasClass("no-refresh") ? false : (res.url ? location.href = res.url : location.reload());
				}, 1500);
            } else {
                showNotify(msg, 'danger');
                selfObj.attr("autocomplete", "on").prop("disabled", false);
            }
        }).fail(function () {
            loader.destroy();
            showNotify('服务器发生错误，请稍后再试', 'danger');
            selfObj.attr("autocomplete", "on").prop("disabled", false);
        });
        
    }
  
    /*
     * 提取通用的通知消息方法
     * @param $msg 提示信息
     * @param $type 提示类型:'info', 'success', 'warning', 'danger'
     * @param $delay 毫秒数，例如：1000
     * @param $icon 图标，例如：'fa fa-user' 或 'glyphicon glyphicon-warning-sign'
     * @param $from 'top' 或 'bottom' 消息出现的位置
     * @param $align 'left', 'right', 'center' 消息出现的位置
     */
    function showNotify($msg, $type, $delay, $icon, $from, $align) {
        $type  = $type || 'info';
        $delay = $delay || 1000;
        $from  = $from || 'top';
        $align = $align || 'right';
        $enter = $type == 'danger' ? 'animated shake' : 'animated fadeInUp';

        jQuery.notify({
            icon: $icon,
            message: $msg
        },
        {
            element: 'body',
            type: $type,
            allow_dismiss: true,
            newest_on_top: true,
            showProgressbar: false,
            placement: {
                from: $from,
                align: $align
            },
            offset: 20,
            spacing: 10,
            z_index: 10800,
            delay: $delay,
            animate: {
                enter: $enter,
                exit: 'animated fadeOutDown'
            }
        });
    }
});
</script>
<script type="text/javascript">
$("#submitbtn").click(function(){
  $.post("?c=Activity&a=editActivity",
  $('#editActivity').serialize(),
  function(status){
      if(status==200){
		  //console.log(id);
          $.notify({
    		// options
    		message: '成功修改',
    		target: '_self'
		  },{
    		// settings
    		type: 'info',
    		delay: 5000,
    		placement: {
    		from: "top",
    		align: "right"
    		}
		  });
      }
      else if(status==501){
          $.notify({
    		// options
    		message: '失败<br>活动已结束，不能做任何修改，否则会导致资金信息脏读',
		  },{
    		// settings
    		type: 'danger',
    		delay: 5000,
    		placement: {
    		from: "top",
    		align: "right"
    		}
		  });
      }else{
          $.notify({
    		// options
    		message: '失败<br>可能是未作修改',
		  },{
    		// settings
    		type: 'danger',
    		delay: 5000,
    		placement: {
    		from: "top",
    		align: "right"
    		}
		  });
      }
	  
});
//这里return false了就能不刷新了
return false;
});
</script>
</body>
</html>